unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, BaseGrid, AdvGrid, RzButton, ExtCtrls, RzPanel;

type
  TKazaGridEvent = procedure (Sender: TObject; ARow, ACol: Integer;var ACellText:string) of object;

  TForm1 = class(TForm)
    AdvGrid1: TAdvStringGrid;
    RzToolbar1: TRzToolbar;
    RzToolButton1: TRzToolButton;
    procedure RzToolButton1Click(Sender: TObject);
    procedure AdvGrid1GetAlignment(Sender: TObject; ARow,
      ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
    procedure FormShow(Sender: TObject);
  private
    FOnKazaGridEvent:TKazaGridEvent;
  public
    procedure OnKazaGridEvent(Sender: TObject; ARow, ACol: Integer;var ACellText:string);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.RzToolButton1Click(Sender: TObject);
var
  I,M:Integer;
  AText:string;
begin
  with AdvGrid1 do
  begin
    ColCount:=10;
    RowCount:=10;
    
    for I:=0 to ColCount-1 do
    begin
      for M:=0 to RowCount-1 do
      begin
        Cells[I,M]:=Format('CELL:%D|%D',[I,M]);
        AText:=Cells[I,M];
        if Assigned(FOnKazaGridEvent) then
        begin
          FOnKazaGridEvent(AdvGrid1,I,M,AText);
        end;
        if AText<>Cells[I,M] then
        begin
          Cells[I,M]:=AText;
        end;  
      end;  
    end;  
  end;  
end;

procedure TForm1.AdvGrid1GetAlignment(Sender: TObject; ARow,
  ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
  //
end;

procedure TForm1.OnKazaGridEvent(Sender: TObject; ARow, ACol: Integer;
  var ACellText: string);
begin
  if (ARow=1) and (ACol=1) then
  begin
    ACellText:='true';
  end else
  begin
    ACellText:='false';
  end;  
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  FOnKazaGridEvent:=OnKazaGridEvent;
end;

end.
